:root {
    /* 亮色主题变量 */
    --light-bg-color: #f0f2f5;
    --light-container-bg: #ffffff;
    --light-text-color: #333333;
    --light-secondary-text: #666666;
    --light-border-color: #eeeeee;
    --light-input-border: #dddddd;
    --light-message-bg: #f4f4f4;
    --light-user-message-bg: #1677ff;
    --light-user-message-color: #ffffff;
    --light-button-bg: #1677ff;
    --light-button-hover: #1668dc;
    --light-button-active: #1554b0;
    --light-scrollbar-track: #f1f1f1;
    --light-scrollbar-thumb: #888888;
    --light-scrollbar-thumb-hover: #555555;
    --light-shadow-color: rgba(0, 0, 0, 0.1);
    --light-settings-bg: #f8f9fa;
    
    /* 暗色主题变量 */
    --dark-bg-color: #1f1f1f;
    --dark-container-bg: #2d2d2d;
    --dark-text-color: #e0e0e0;
    --dark-secondary-text: #a0a0a0;
    --dark-border-color: #444444;
    --dark-input-border: #555555;
    --dark-message-bg: #3a3a3a;
    --dark-user-message-bg: #1677ff;
    --dark-user-message-color: #ffffff;
    --dark-button-bg: #1677ff;
    --dark-button-hover: #1668dc;
    --dark-button-active: #1554b0;
    --dark-scrollbar-track: #2d2d2d;
    --dark-scrollbar-thumb: #666666;
    --dark-scrollbar-thumb-hover: #888888;
    --dark-shadow-color: rgba(0, 0, 0, 0.3);
    --dark-settings-bg: #252525;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* 亮色主题 */
body.theme-light {
    --bg-color: var(--light-bg-color);
    --container-bg: var(--light-container-bg);
    --text-color: var(--light-text-color);
    --secondary-text: var(--light-secondary-text);
    --border-color: var(--light-border-color);
    --input-border: var(--light-input-border);
    --message-bg: var(--light-message-bg);
    --user-message-bg: var(--light-user-message-bg);
    --user-message-color: var(--light-user-message-color);
    --button-bg: var(--light-button-bg);
    --button-hover: var(--light-button-hover);
    --button-active: var(--light-button-active);
    --scrollbar-track: var(--light-scrollbar-track);
    --scrollbar-thumb: var(--light-scrollbar-thumb);
    --scrollbar-thumb-hover: var(--light-scrollbar-thumb-hover);
    --shadow-color: var(--light-shadow-color);
    --settings-bg: var(--light-settings-bg);
}

/* 暗色主题 */
body.theme-dark {
    --bg-color: var(--dark-bg-color);
    --container-bg: var(--dark-container-bg);
    --text-color: var(--dark-text-color);
    --secondary-text: var(--dark-secondary-text);
    --border-color: var(--dark-border-color);
    --input-border: var(--dark-input-border);
    --message-bg: var(--dark-message-bg);
    --user-message-bg: var(--dark-user-message-bg);
    --user-message-color: var(--dark-user-message-color);
    --button-bg: var(--dark-button-bg);
    --button-hover: var(--dark-button-hover);
    --button-active: var(--dark-button-active);
    --scrollbar-track: var(--dark-scrollbar-track);
    --scrollbar-thumb: var(--dark-scrollbar-thumb);
    --scrollbar-thumb-hover: var(--dark-scrollbar-thumb-hover);
    --shadow-color: var(--dark-shadow-color);
    --settings-bg: var(--dark-settings-bg);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-color);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--text-color);
    transition: background-color 0.3s ease;
}

.chat-container {
    width: 90%;
    max-width: 800px;
    height: 90vh;
    background-color: var(--container-bg);
    border-radius: 12px;
    box-shadow: 0 2px 10px var(--shadow-color);
    display: flex;
    flex-direction: column;
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    text-align: center;
}

.chat-header h1 {
    font-size: 1.5rem;
    color: var(--text-color);
    margin: 0;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    position: relative;
    contain: strict;
    will-change: transform;
}

.message {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.message.user {
    align-items: flex-end;
}

.message.bot {
    align-items: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.user .message-content {
    background-color: var(--user-message-bg);
    color: var(--user-message-color);
    border-radius: 12px 12px 0 12px;
}

.bot .message-content {
    background-color: var(--message-bg);
    color: var(--text-color);
    border-radius: 12px 12px 12px 0;
}

.chat-input {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    background-color: var(--container-bg);
    align-items: center;
}

.icon-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-color);
    transition: background-color 0.3s ease;
}

.icon-button:hover {
    background-color: var(--message-bg);
}

/* 文件预览样式 */
.file-preview {
    margin: 10px 0;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    background-color: var(--message-bg);
}

.file-preview img,
.file-preview video {
    max-width: 100%;
    max-height: 300px;
    display: block;
}

.file-preview audio {
    width: 100%;
}

.file-icon {
    padding: 15px;
    text-align: center;
    color: var(--text-color);
}

/* 上传进度条 */
.upload-progress {
    width: 100%;
    height: 4px;
    background-color: var(--border-color);
    border-radius: 2px;
    margin-top: 5px;
    position: relative;
}

.progress-bar {
    height: 100%;
    background-color: var(--button-bg);
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    position: absolute;
    right: 0;
    top: -20px;
    font-size: 0.8rem;
    color: var(--secondary-text);
}

#userInput {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 0.95rem;
    outline: none;
    transition: border-color 0.3s ease;
    background-color: var(--container-bg);
    color: var(--text-color);
}

#userInput:focus {
    border-color: var(--button-bg);
}

#sendButton {
    padding: 12px 24px;
    background-color: var(--button-bg);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color 0.3s ease;
}

#sendButton:hover {
    background-color: var(--button-hover);
}

#sendButton:active {
    background-color: var(--button-active);
}

/* 添加滚动条样式 */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: var(--scrollbar-track);
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

/* 主题切换开关样式 */
.theme-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.theme-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--message-bg);
    transition: .4s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: var(--container-bg);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--button-bg);
}

input:checked + .slider:before {
    transform: translateX(26px);
}

/* 设置栏样式 */
.settings-bar {
    background-color: var(--settings-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 10px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 20px;
    align-items: center;
    transition: background-color 0.3s ease;
}

/* 语言选择器样式更新 */
.language-selector select {
    background-color: var(--container-bg);
    color: var(--text-color);
    border: 1px solid var(--input-border);
    padding: 5px;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.language-selector select:hover {
    border-color: var(--button-bg);
}

/* 错误消息样式更新 */
.error-message {
    color: #ff4d4f;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    display: none;
    transition: color 0.3s ease;
}

/* 搜索栏样式 */
.search-bar {
    display: none;
    padding: 10px;
    background-color: var(--settings-bg);
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    gap: 10px;
}

.search-bar.active {
    display: flex;
}

#searchInput {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--input-border);
    border-radius: 20px;
    font-size: 0.9rem;
    outline: none;
    background-color: var(--container-bg);
    color: var(--text-color);
}

.search-results {
    display: none;
    position: absolute;
    top: 100px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 800px;
    max-height: 60vh;
    overflow-y: auto;
    background-color: var(--container-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-color);
    z-index: 100;
    padding: 10px;
}

.search-results.active {
    display: block;
}

.search-result {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-result:hover {
    background-color: var(--message-bg);
}

.search-result-sender {
    font-weight: bold;
    color: var(--text-color);
}

.search-result-time {
    font-size: 0.8rem;
    color: var(--secondary-text);
    margin: 4px 0;
}

.search-result-content {
    font-size: 0.9rem;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.search-highlight {
    background-color: rgba(255, 235, 59, 0.3);
    font-weight: bold;
}

.search-no-results {
    padding: 20px;
    text-align: center;
    color: var(--secondary-text);
}

.message-highlight {
    animation: highlight-fade 3s ease-out;
    border-left: 4px solid #1677ff;
    background-color: rgba(22, 119, 255, 0.1) !important;
}

@keyframes highlight-fade {
    0% {
        background-color: rgba(22, 119, 255, 0.3);
    }
    100% {
        background-color: rgba(22, 119, 255, 0.1);
    }
}